package com.qingzhu.dao.impl;

import com.qingzhu.dao.AreasDao;
import com.qingzhu.pojo.Areas;
import com.qingzhu.util.CreateSqlSessionFactory;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class AreasDaoImpl implements AreasDao {

    @Override
    public List<Areas> findByCitiesId(String citiesId) {
        try (SqlSession sqlSession = CreateSqlSessionFactory.getFactory().openSession(true)){
            AreasDao areasDao = sqlSession.getMapper(AreasDao.class);
            return areasDao.findByCitiesId(citiesId);
        }
    }

    @Override
    public Areas findAreasById(String areaId) {
        try (SqlSession sqlSession = CreateSqlSessionFactory.getFactory().openSession(true)){
            AreasDao areasDao = sqlSession.getMapper(AreasDao.class);
            return areasDao.findAreasById(areaId);
        }
    }
}
